package info

import (
	"fmt"
	"io"
	"log"
	"os"

	"gitee.com/chuanjinge/go-container/container/containerconfig"
)

// 运行日志信息
func PrintRunLog(containerId string) {
	runLogPath := containerconfig.GetRunLogPath(containerId)
	file, err := os.Open(runLogPath)
	if err != nil {
		log.Printf("Log container open file %s error %v\n", runLogPath, err)
		return
	}
	defer file.Close()

	content, err := io.ReadAll(file)
	if err != nil {
		log.Printf("Log container read file %s error %v\n", runLogPath, err)
		return
	}
	_, err = fmt.Fprint(os.Stdout, string(content))
	if err != nil {
		log.Printf("Log container Fprint  error %v\n", err)
		return
	}
}
